/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-11-23     86159       the first version
 */

#include"thread.h"
void th1_entry(void *parameter)
{
    while(1)
    {
        rt_kprintf("th1_entry running...\n");
        rt_thread_mdelay(1000);
    }
}

void th2_entry(void *parameter)
{
    int i=0;
    for(i=0;i<10;i++)
    {
        rt_kprintf("th2_entry running...\n");
        rt_thread_mdelay(1000);
    }
}
int thread(void)
{
    int ret=0;
    rt_thread_t th1_ptr=RT_NULL;
    rt_uint8_t th2_stack[512]={0};
    th1_ptr=rt_thread_create("th1_demo", th1_entry, RT_NULL, 1024, 20, 5);
    if(th1_ptr==RT_NULL)
    {
        LOG_E("rt_creat failed...\n");
        return -RT_ENOMEM;
    }
    LOG_D("rt_creat successed...\n");
    rt_thread_startup(th1_ptr);

    ret=rt_thread_init(&th2, "th2_demo", th2_entry, RT_NULL, th2_stack, sizeof(th2_stack), 19, 5);
    if(ret<0)
    {
        LOG_E("rt_thread_init failed...\n");
        return ret;
    }
        LOG_D("rt_thread_init successed...\n");
        rt_thread_startup(&th2);
        return 0;
}
